package com.shiyi.system.controller;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shiyi.core.utils.result.Result;
import com.shiyi.system.annotation.OperaLog;
import com.shiyi.system.entity.OperationLog;
import com.shiyi.system.service.OperationLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author shiyi
 * @since 2020-12-08
 */
@Api(tags = "日志管理")
@RestController
@RequestMapping("/system/log")
public class OperationLogController {

    @Autowired
    private OperationLogService operationLogService;


    @ApiOperation("日志管理")
    @GetMapping("/list")
    public Result<PageInfo<OperationLog>> list(@RequestParam(required = false) Integer type,
                               @RequestParam(required = false) String keyword,
                               @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
                               @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<OperationLog> operationLogs = operationLogService.listLog(type, keyword);
        PageInfo<OperationLog> info = new PageInfo<>(operationLogs);
        return Result.success(info);
    }
}

